<%@page contentType="text/html" pageEncoding="UTF-8" import="java.io.*, java.sql.*, javax.sql.*"%>
<%
    response.setHeader("Cache-Control", "no-cache");
    response.setHeader("Pragma", "no-cache");
    response.setDateHeader("Expires", -1);
    String gotoTab = (String) session.getAttribute("gotoTab");
    Connection con = com.elookinto.wordlist.Util.getCon();
    String uid = (String) session.getAttribute("uid");
    if (uid == null) {
        return;
    }
    PreparedStatement st = con.prepareStatement("Select distinct listname  from wordlist where uid=? order by listname");
    st.setString(1, uid);
    response.setHeader("Access-Control-Allow-Origin", "*");
    String server = request.getServerName();
    String word = request.getParameter("myword");
%>
<br/>
<div>
<Select style="float: right" onchange='
    var listName = this.options[this.selectedIndex].text;
    var word = "<%=word%>";
    if (word=="" && document.getElementById("myword")!=null) {
        word = document.getElementById("myword").value;
    }
var gotoTab = document.getElementById("gotoTab").checked;
var win = window.open("http://www.elookinto.com/wordlist/index.jsp?listName=" + listName + "&word="+ word + "&gotoTab=" + gotoTab  , "elookinto"); 
if (document.getElementById("chrome_ggl_dict_ext") != null)
    document.getElementById("chrome_ggl_dict_ext").style.display="none";
$(win.document).ready(function() {
    if (!document.getElementById("gotoTab").checked) {
        window.focus();
    } else 
    {
        win.focus();
    }
})
        '> 
    <option   style="color:brown"> --------- </option>
    <option   style="color:brown"> Recent </option>
    <%
        st = con.prepareStatement("Select distinct listname  from wordlist where uid=? order by listname");
        st.setString(1, uid);

        ResultSet rs = st.executeQuery();
        while (rs.next()) {
            String mylistName = rs.getString("listname");
            if (mylistName.equals("Recent")) {
                continue;
            }
            out.println("<option class='edit'><a href='#" + mylistName + "'>" + mylistName + "</option>");
        }
    %>

</select>

<span style="font-weight:bold;color:brown!important;float:right;margin-top:0px">
    Add this word to my list   (<label for='gotoTab' style="display: inline;color:lightblue!important"> Go to  Word List Tab? </label>
    <input  <%= "true".equals(gotoTab) ? "checked" : ""%> style="display: inline" id="gotoTab" type="checkbox" />  ):
</span>

</div>
<%
    rs.close();
    st.close();
    con.close();
%>

